#!/bin/bash
# set -e
# set git config
# config_path=
git config --global user.name "sadsag"
git config --global user.email "safaf@sdaf.sad"
git config --global credential.helper store
git config --global core.quotepath false
# echo '# Enforce SSH
# [url "https://gh-proxy.com/https://github.com/"]
#     insteadOf = https://github.com/' >> ~/.gitconfig
mkdir ~/build
mkdir ~/coding
mkdir -p $config_path
# git config --global http.sslVerify false # Do NOT do this!
# ssh and key 
mkdir ~/.ssh
cp ~/archinstall/id_ed25519 ~/.ssh/
chmod 700 ~/.ssh
chmod 600 ~/.ssh/*
ssh-keygen -p
cd ~/archinstall
git remote remove origin
git remote add origin git@gitcode.com:a365021880/archinstall.git
git push --set-upstream origin master
cd $config_path/..
git clone git@gitcode.com:a365021880/config
git clone git@gitcode.com:a365021880/private
git clone git@gitcode.com:a365021880/work
# mkdir ~/.config/environment.d
# echo 'SSH_ASKPASS=/usr/bin/ksshaskpass
# SSH_ASKPASS_REQUIRE=prefer' > ~/.config/environment.d/ssh_askpass.conf

# echo 'Host github.com
#     Hostname ssh.github.com
#     Port 443
#     User git' > ~/.ssh/config
# echo 'Host github.com
#     Hostname 1.ghmain.steam302.xyz
#     User git' > ~/.ssh/config
#
# edit .inputrc
balooctl6 disable
echo 'set show-all-if-ambiguous on
# Color files by types
# Note that this may cause completion text blink in some terminals (e.g. xterm).
set colored-stats On
# Append char to indicate type
set visible-stats On
# Mark symlinked directories
set mark-symlinked-directories On
# Color the common prefix
set colored-completion-prefix On
# Color the common prefix in menu-complete
set menu-complete-display-prefix On
set completion-ignore-case on' >> ~/.inputrc
# # password
# echo "set your home password"
# read passwd
# echo "export password=$passwd" >> ~/.bashrc
# PATH
echo 'export PATH=$PATH:~/archinstall/bin/' >> ~/.bashrc
# alias
echo '# Enc_7z -p(password) a output.7z source_file
alias Enc_7z="7z -mhe=on -mx=0"
alias WineCN="LC_ALL=zh_CN wine"
alias Yt-dlp="yt-dlp --cookies-from-browser firefox"' >> ~/.bashrc
# variables
echo 'export GOPROXY=https://goproxy.io,direct
export EDITOR=vim' >> ~/.bashrc
# bash_profile
# echo 'setleds -D +num' >> ~/.bash_profile
# redshift
echo '[redshift]
temp-day=3600
temp-night=3600
#gamma=0.8
adjustment-method=randr
location-provider=manual
[manual]
lat=55.7
lon=12.6' >> ~/.config/redshift.conf
# software files
# xdg-user-dirs-update
## mkdir $config_path
# cp ~/archinstall/home.7z ~/Videos/
# cd $config_path
# 7z x home.7z
# tar xf back.tar
# cp -r Videos/* .
# rm -rf Videos/
# rm home.7z back.tar
## cp backup.sh ~/
cd
mkdir -p ~/.config/systemd/user/
cp $config_path/steamcommunity/my_steam.service ~/.config/systemd/user/
cp $config_path/phantomsocks/phantomsocks.service ~/.config/systemd/user/
cp $config_path/dnscrypt/dnscrypt-proxy.service ~/.config/systemd/user/
cp $config_path/aria2/aria2c.service ~/.config/systemd/user/
# software config
cp -r /usr/share/doc/mpv/ ~/.config/
echo 'save-position-on-quit
hwdec=auto
audio-channels=mono' >> ~/.config/mpv/mpv.conf
mkdir ~/.aria2
echo 'async-dns=false
min-split-size=1M
split=16
max-connection-per-server=16
#user-agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 GLS/100.10.9939.100"
user-agent=Chrome
continue=true
check-certificate=false' > ~/.aria2/aria2.conf
echo '--enable-features=VaapiVideoDecodeLinuxGL
--enable-features=VaapiIgnoreDriverChecks' > ~/.config/chromium-flags.conf
# pipx install usb_resetter
python $HOME/archinstall/software/zsh.py
sudo python $HOME/archinstall/software/zsh.py
# python /home/h/archinstall/software/firefox.py

# config
mkdir ~/.cargo
echo '[source.crates-io]
replace-with = "rsproxy-sparse"
[source.rsproxy]
registry = "https://rsproxy.cn/crates.io-index"
[source.rsproxy-sparse]
registry = "sparse+https://rsproxy.cn/index/"
[registries.rsproxy]
index = "https://rsproxy.cn/crates.io-index"
[net]
git-fetch-with-cli = true' > ~/.cargo/config.toml
mkdir ~/.config/git
echo '.*' > ~/.config/git/ignore
cp -r ~/archinstall/settings/fcitx5 ~/.config/
# cp ~/archinstall/settings/alsamixer.rc ~/.config/
chsh -s /usr/bin/zsh

# python
python -m venv ~/.local/python
mkdir ~/.pip
echo '[global]
index-url = https://mirrors.huaweicloud.com/repository/pypi/simple
trusted-host = mirrors.huaweicloud.com
timeout = 120' | tee ~/.pip/pip.conf

# keyboard shortcut
xfconf-query -c xfce4-keyboard-shortcuts -n -t 'string' -p "/commands/custom/<shift>F12" -s "amixer -D pulse sset Master 5%+"
xfconf-query -c xfce4-keyboard-shortcuts -n -t 'string' -p "/commands/custom/<shift>F11" -s "amixer -D pulse sset Master 5%-"

# fonts
mkdir ~/.config/fontconfig
mkdir ~/.local/share/fonts
cp ~/archinstall/software/fonts.conf ~/.config/fontconfig/fonts.conf

# auto start


setting_path="$HOME/archinstall/settings"
mkdir ~/.config/htop
cp $setting_path/htoprc $HOME/.config/htop/
sudo cp $setting_path/makepkg.conf /etc/makepkg.conf

# graphics
# echo '<driconf>
#    <device>
#        <application name="Default">
#            <option name="vblank_mode" value="0" />
#        </application>
#    </device>
# </driconf>' > $HOME/.drirc

# auto backup 
# mkdir -p /var/spool/cron
# echo '*/10 * * * * /home/h/archinstall/bin/Sync_private.sh' > /var/spool/cron/h

gpg --import ~/archinstall/365021880.txt
gpg --edit-key 3 trust quit
gpg --edit-key 3 passwd quit
mkdir ~/.local/bin
